Skip to content

Fix(#50): GSB API 키가 httpx INFO 로그에 노출되는 문제 - #51

Merged
pearseona merged 3 commits into
developfrom
fix/gsb-httpx-key-log-leak
Aug 10, 2026
Merged

Fix(#50): GSB API 키가 httpx INFO 로그에 노출되는 문제#51
pearseona merged 3 commits into
developfrom
fix/gsb-httpx-key-log-leak

Conversation

@kite-pp

@kite-pp kite-pp commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

📝 개요

Google Safe Browsing API 키가 httpx의 INFO 레벨 요청 로그를 통해 그대로 노출되는 문제를 수정합니다. GSB API는 키를 URL 쿼리 파라미터로 요구하는데, 저장소에 httpx 로거를 억제하는 설정이 없어 INFO 이상 로깅이 켜지는 환경(로컬 디버깅, 임시 스크립트 등)에서 키가 로그에 그대로 찍힙니다. 벤치마크 테스트 스크립트 작업 중 실제로 발견했습니다.

🔗 관련 이슈

🎯 주요 변경 사항

  • app/infrastructure/google_safe_browsing/client.py: 모듈 임포트 시점에 httpx/httpcore 로거를 WARNING 이상으로 고정. 앱 진입점(app.main)뿐 아니라 이 클라이언트를 직접 임포트하는 임시 스크립트에서도 동일하게 보호되도록 클라이언트 모듈 자체에 배치.
  • VirusTotal은 헤더 인증(x-apikey)이라 해당 없음, 별도 수정 불필요.

📸 사진

생략

✅ PR 체크리스트

  • 관련 이슈를 연결했습니다.
  • 구현 범위와 변경 이유를 설명했습니다.
  • 로컬 테스트(uvicorn 구동 또는 테스트 코드)를 통과했습니다. (215건 통과)
  • API 변경 사항이 있다면 Swagger / API 명세에 반영했습니다. (해당 없음)
  • 민감 정보(API Key, 시크릿 키 등)가 코드·로그·테스트 데이터에 포함되지 않았습니다.
  • 프론트엔드 또는 메인 백엔드(Spring)에 영향을 주는 응답 스키마 또는 Enum 변경이 있다면 팀에 공유했습니다. (해당 없음)
  • 병합(Merge) 전 작업 브랜치를 삭제하지 않았습니다.

⚠️ 별도 조치 필요

이미 노출된 GOOGLE_SAFE_BROWSING_API_KEY는 이 PR과 별개로 재발급(rotate)이 필요합니다.

Summary by CodeRabbit

  • Bug Fixes
    • Improved security by preventing sensitive API keys in request URLs from appearing in informational logs.

Google Safe Browsing API는 키를 URL 쿼리 파라미터로 요구하는데, httpx는
INFO 레벨에서 요청 URL 전체를 그대로 로깅한다. INFO 이상 로깅이 켜지는
환경(로컬 디버깅, 임시 스크립트 등)에서 키가 로그에 그대로 노출될 수 있어,
이 클라이언트를 임포트하는 시점에 httpx/httpcore 로거를 WARNING 이상으로
고정한다.

VirusTotal은 헤더 인증(x-apikey)이라 해당 없음.
@kite-pp kite-pp added the fix Bug fixes or pathces for unintended behaviors label Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Safe Browsing client now sets httpx and httpcore logger levels to WARNING during module import.

Changes

Safe Browsing logging control

Layer / File(s) Summary
HTTP client logger configuration
app/infrastructure/google_safe_browsing/client.py
The module sets the httpx and httpcore logger levels to WARNING at import time.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: pearseona

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 GSB API 키가 httpx INFO 로그에 노출되는 문제를 명확히 설명하며 주요 변경 사항과 일치합니다.
Linked Issues check ✅ Passed 변경 사항은 #50의 핵심 코딩 요구사항인 httpx와 httpcore 로거의 WARNING 이상 설정을 충족합니다.
Out of Scope Changes check ✅ Passed 변경 사항은 Google Safe Browsing 클라이언트의 로그 노출 방지에만 해당하며 범위를 벗어난 코드 변경이 없습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/gsb-httpx-key-log-leak

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
app/infrastructure/google_safe_browsing/client.py (2)

13-14: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

프로세스 전체 HTTPX 로그 억제의 범위를 확인해 주세요.

Line 13-14는 프로세스 전체의 httpxhttpcore 로거를 변경합니다. 따라서 GoogleSafeBrowsingClient뿐 아니라 다른 HTTP 클라이언트의 INFO 요청 로그도 사라집니다. VirusTotal을 포함한 다른 연동의 관측성이 감소할 수 있습니다. 이 전역 동작이 의도된 것인지 확인해 주세요. 의도되지 않았다면 key 쿼리 파라미터만 제거하는 로그 필터를 사용해 주세요.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/infrastructure/google_safe_browsing/client.py` around lines 13 - 14,
Remove the global logger-level changes for “httpx” and “httpcore” near
GoogleSafeBrowsingClient, and replace them with a client-scoped logging filter
that removes only the key query parameter from Google Safe Browsing request
logs. Preserve INFO-level logging for other HTTP clients and integrations,
including VirusTotal.

13-14: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

API 키 누출 방지에 대한 회귀 테스트를 추가해 주세요.

가짜 API 키를 사용하고 네트워크 전송은 mock transport로 대체한 뒤, httpxhttpcore 로그에 해당 키가 포함되지 않는지 검증해 주세요. 로거 레벨만 확인하지 말고 실제 AsyncClient.post 경로를 검증해야 합니다. HTTPX 0.27.0은 sync/async INFO 요청 로그에 request.url을 포함합니다. (raw.githubusercontent.com)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/infrastructure/google_safe_browsing/client.py` around lines 13 - 14,
애플리케이션의 HTTP 요청 테스트에 가짜 API 키와 mock transport를 적용하고, 실제 AsyncClient.post 경로를 실행해
검증하는 회귀 테스트를 추가하세요. 요청 처리 중 httpx 및 httpcore 로그를 캡처한 뒤 모든 로그 메시지에 가짜 키가 포함되지 않는지
확인하고, 로거 레벨만 검사하는 테스트는 작성하지 마세요.

Source: MCP tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/infrastructure/google_safe_browsing/client.py`:
- Around line 13-14: Remove the global logger-level changes for “httpx” and
“httpcore” near GoogleSafeBrowsingClient, and replace them with a client-scoped
logging filter that removes only the key query parameter from Google Safe
Browsing request logs. Preserve INFO-level logging for other HTTP clients and
integrations, including VirusTotal.
- Around line 13-14: 애플리케이션의 HTTP 요청 테스트에 가짜 API 키와 mock transport를 적용하고, 실제
AsyncClient.post 경로를 실행해 검증하는 회귀 테스트를 추가하세요. 요청 처리 중 httpx 및 httpcore 로그를 캡처한 뒤
모든 로그 메시지에 가짜 키가 포함되지 않는지 확인하고, 로거 레벨만 검사하는 테스트는 작성하지 마세요.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fcdb1af3-31ef-47c7-bef4-50a1173aa95d

📥 Commits

Reviewing files that changed from the base of the PR and between 00b3544 and f18b68c.

📒 Files selected for processing (1)
  • app/infrastructure/google_safe_browsing/client.py

@pearseona
pearseona merged commit 5b16971 into develop Aug 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fixes or pathces for unintended behaviors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fix] GSB API 키가 httpx INFO 로그에 노출되는 문제

2 participants